﻿import com.dinmax.isolution.*

class ButtonBarGUI
extends MovieClip {
		
	private var listener:Object;	
	private var activeButton:AppButtonGUI;
			
	function ButtonBarGUI(){
		
		return;
	}
	
	function onLoad(){
		this.listener = ISAppGUI.getActive().registerButtonBar(this);
		return;
	}
	
	public function registerChild(btn:AppButtonGUI):Void {
		switch(btn._name){
			case "mcThemeButton":
			btn.setWindow("themes");
			break;
			
			case "mcDeviceButton":
			btn.setWindow("devices");
			break;
			
			case "mcCalendarButton":
			btn.setWindow("calendar");
			break;
		}
		return;
	}
	
	public function setDisabled():Void {
		trace("ButtonBarGUI | setDisabled");
		this.activeButton.onPress();
		return;
	}
	
	public function onChange(btn:AppButtonGUI, type:String):Void {
		if(type == "enabled") {
			if(btn.getEnabled() && btn != activeButton){
				activeButton.setEnabled(false);
				activeButton = btn;
				listener.showWindow(btn.getWindow());
								
			} else if(!btn.getEnabled() && btn==activeButton) {
				activeButton = null;
				listener.hideWindow();
			}
		}
		return;
	}
	
}